<meta charset="utf-8">
(#) Companion objects should not be annotated with @Module

!!! WARNING: Companion objects should not be annotated with @Module
   This is a warning.

Id
:   `ModuleCompanionObjectsNotInModuleParent`
Summary
:   Companion objects should not be annotated with @Module
Severity
:   Warning
Category
:   Correctness
Platform
:   Any
Vendor
:   Google
Identifier
:   com.google.dagger:dagger-lint
Contact
:   https://github.com/google/dagger
Feedback
:   https://github.com/google/dagger/issues
Min
:   Lint 7.1
Compiled
:   Lint 7.1
Artifact
:   [com.google.dagger:dagger-lint](com_google_dagger_dagger-lint.md.html)
Since
:   2.40.2
Affects
:   Kotlin and Java files and test sources
Editing
:   This check runs on the fly in the IDE editor
Implementation
:   [Source Code](https://github.com/google/dagger/tree/master/java/dagger/lint/DaggerKotlinIssueDetector.kt)
Tests
:   [Source Code](https://github.com/google/dagger/tree/master/javatests/dagger/lint/DaggerKotlinIssueDetectorTest.kt)
Copyright Year
:   2020

Companion objects in @Module-annotated classes are considered part of
the API. This
companion object is not a companion to an @Module-annotated class
though, and should be
moved to a top-level object declaration instead otherwise Dagger will
ignore companion
object.

(##) Including

!!!
   This is not a built-in check. To include it, add the below dependency
   to your project.

```
// build.gradle.kts
implementation("com.google.dagger:dagger-lint:2.55")

// build.gradle
implementation 'com.google.dagger:dagger-lint:2.55'

// build.gradle.kts with version catalogs:
implementation(libs.dagger.lint)

# libs.versions.toml
[versions]
dagger-lint = "2.55"
[libraries]
# For clarity and text wrapping purposes the following declaration is
# shown split up across lines, but in TOML it needs to be on a single
# line (see https://github.com/toml-lang/toml/issues/516) so adjust
# when pasting into libs.versions.toml:
dagger-lint = {
    module = "com.google.dagger:dagger-lint",
    version.ref = "dagger-lint"
}
```

2.55 is the version this documentation was generated from;
there may be newer versions available.

[Additional details about com.google.dagger:dagger-lint](com_google_dagger_dagger-lint.md.html).
(##) Suppressing

You can suppress false positives using one of the following mechanisms:

* Using a suppression annotation like this on the enclosing
  element:

  ```kt
  // Kotlin
  @Suppress("ModuleCompanionObjectsNotInModuleParent")
  fun method() {
     problematicStatement()
  }
  ```

  or

  ```java
  // Java
  @SuppressWarnings("ModuleCompanionObjectsNotInModuleParent")
  void method() {
     problematicStatement();
  }
  ```

* Using a suppression comment like this on the line above:

  ```kt
  //noinspection ModuleCompanionObjectsNotInModuleParent
  problematicStatement()
  ```

* Using a special `lint.xml` file in the source tree which turns off
  the check in that folder and any sub folder. A simple file might look
  like this:
  ```xml
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;lint&gt;
      &lt;issue id="ModuleCompanionObjectsNotInModuleParent" severity="ignore" /&gt;
  &lt;/lint&gt;
  ```
  Instead of `ignore` you can also change the severity here, for
  example from `error` to `warning`. You can find additional
  documentation on how to filter issues by path, regular expression and
  so on
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).

* In Gradle projects, using the DSL syntax to configure lint. For
  example, you can use something like
  ```gradle
  lintOptions {
      disable 'ModuleCompanionObjectsNotInModuleParent'
  }
  ```
  In Android projects this should be nested inside an `android { }`
  block.

* For manual invocations of `lint`, using the `--ignore` flag:
  ```
  $ lint --ignore ModuleCompanionObjectsNotInModuleParent ...`
  ```

* Last, but not least, using baselines, as discussed
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).

<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>